import request from '@/utils/request';
/**
 * 站点列表增加
 * @param params 查询条件
 */

export async function siteCategoriesInsert(data) {
  const res = await request.post(
    '/api/TechnicianEnd/service-categories/save',
    data
  );
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 分类列表查询
 * @param params 查询条件
 */

export async function siteCategoriesList(params) {
  const res = await request.get('/api/TechnicianEnd/service-categories/page', {
    params
  });
  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 站点列表修改
 * @param params 查询条件
 */
export async function siteCategoriesModify(data) {
  const res = await request.put(
    '/api/TechnicianEnd/service-categories/update',
    data
  );
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 站点列表查询
 * @param params 查询条件
 */

export async function siteCategoriesDetail(id) {
  const res = await request.get('/api/TechnicianEnd/service-categories/' + id);

  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 站点列表删除
 * @param params 查询条件
 */

export async function sitecCategoriesDelete(id) {
  const res = await request.delete(
    '/api/TechnicianEnd/service-categories/' + id
  );
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 批量删除服务类目
 * @param params 查询条件
 */

export async function siteBatchCategoriesDelete(data) {
  const res = await request.delete(
    '/api/TechnicianEnd/service-categories/batch',
    {
      data
    }
  );
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
